package com.material.vtool.controller;

import com.google.common.collect.Maps;
import com.material.vtool.entity.BTeamMaterialTypeEntity;
import com.material.vtool.entity.combinedEntity.TeamMaterialLabelEntity;
import com.material.vtool.entity.respEntity.RespData;
import com.material.vtool.entity.respEntity.ReturnCode;
import com.material.vtool.service.TeamMaterialTypeService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;

/**
 * 团队标签
 */
@RestController
@RequestMapping("/teamLable")
public class TeamMaterialTypeController {
    @Autowired
    private TeamMaterialTypeService teamMaterialTypeService;

    /**
     * 获取团队的标签
     * @param teamId 团队ID
     * @return
     */
    @GetMapping(value = "/list", produces = "application/json;charset=UTF-8")
    public RespData list(@RequestParam String teamId) {
        if (StringUtils.isBlank(teamId) || !StringUtils.isNumeric(teamId)) {
            RespData respData = new RespData();
            respData.setCode(ReturnCode.CLIENT_ERROR);
            respData.setMsg("参数错误");
            return respData;
        }
        List<TeamMaterialLabelEntity> teamLableList = teamMaterialTypeService.getTeamLableList(Integer.valueOf(teamId));

        HashMap<String, Object> resultMap = Maps.newHashMapWithExpectedSize(10);
        resultMap.put("teamLableList", teamLableList);

        RespData respData = new RespData();
        respData.setCode(ReturnCode.NORMAL_SUCC);
        respData.setMsg("成功");
        respData.setData(resultMap);
        return respData;
    }

    // 修改标签
}
